'use strict';

const Controller = require('egg').Controller;

class UserAccountController extends Controller {
  constructor(ctx) {
    super(ctx);
    this.events = ctx.service.providers.userServiceProvider.boot();
  }

  async register() {
    const { ctx } = this;

    const newAccount = {
      uid: 1,
      nickname: '新用户',
    };

    this.events.emit('RegisterNewAccount', newAccount);

    ctx.body = {
      rtcode: 0,
      message: '新用户注册成功',
      data: newAccount,
    };

  }
}

module.exports = UserAccountController;
